from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from django.views.static import serve
import os

# 打印媒体路径信息用于调试
print(f"Django设置的MEDIA_ROOT: {settings.MEDIA_ROOT}")
print(f"Django设置的MEDIA_URL: {settings.MEDIA_URL}")

# 确保media目录存在
os.makedirs(settings.MEDIA_ROOT, exist_ok=True)
os.makedirs(os.path.join(settings.MEDIA_ROOT, 'reports'), exist_ok=True)

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('app.urls')),  # 包含app应用的URLs
    path('amazon/', include('app.urls_amazon_auth')),
    path('ebay/', include('ebay.urls')),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

# DEBUG模式下提供静态文件和媒体文件
if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) 
